/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * WindowGUI.java
 *
 * Created on 11.12.2009, 15:37:24
 */

package neuronalenetzeelearning.model;

import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import neuronalenetzeelearning.view.gui.GraphVisualization;
import java.lang.Math;

/**
 *
 * @author Henning
 */
public class WindowGUI extends javax.swing.JFrame {

    private final int Hebb = 0;
    private final int Delta = 1;
    private final int Random = 0;
    private final int Self = 1;
    private final int Step = 0;
    private final int Run = 1;

    public String LearningRule = "Hebbsche Lernregel";
    public String RunningType = "Schrittweise";
    public String WightDefType = "Zufall";
    public int RunValue = 0;
    public Graph graphGUI = new Graph();
    private int KnotenNumber = 1;
    private int KantenNumber = 1;

    private boolean Box4;
    private boolean Box5;
    private boolean Box6;
    private boolean Box7;
    private boolean Box8;
    private boolean Box9;

    private boolean button4;
    private boolean button5;
    private boolean button6;
    private boolean button7;

    /** Creates new form WindowGUI */
    public WindowGUI() {
        initComponents();
        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jDialog1 = new javax.swing.JDialog();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jDialog2 = new javax.swing.JDialog();
        jButton3 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jFormattedTextField1 = new javax.swing.JFormattedTextField();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jComboBox1 = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel6 = new javax.swing.JLabel();
        LearningRuleComboBox = new javax.swing.JComboBox();
        WeightModeComboBox = new javax.swing.JComboBox();
        StepModeComboBox = new javax.swing.JComboBox();
        StepValueSpinner = new javax.swing.JSpinner();
        StartCalculationButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        InterruptCalculationButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        Adjazenzmatrix = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        SetGraphButton = new javax.swing.JButton();
        AddNodeToGraphButton = new javax.swing.JButton();
        AddEdgeToGraph = new javax.swing.JButton();
        NodeLayerComboBox = new javax.swing.JComboBox();
        DeleteNodeFromGraph = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JSeparator();
        DeleteEdgeFromGraph = new javax.swing.JButton();
        DeleteNodeLayer = new javax.swing.JComboBox();
        AddEgdeFromNode = new javax.swing.JComboBox();
        AddEgdeToNode = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        DeleteEdgeComboBox = new javax.swing.JComboBox();
        DeleteNodeComboBox = new javax.swing.JComboBox();
        jFileChooser1 = new javax.swing.JFileChooser();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        jDialog1.setMinimumSize(new java.awt.Dimension(500, 200));
        jDialog1.setName("jDialog1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(neuronalenetzeelearning.testgui.NeuronaleNetzeELearningApp.class).getContext().getResourceMap(WindowGUI.class);
        jButton8.setText(resourceMap.getString("jButton8.text")); // NOI18N
        jButton8.setName("jButton8"); // NOI18N
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setText(resourceMap.getString("jButton9.text")); // NOI18N
        jButton9.setName("jButton9"); // NOI18N
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setRows(5);
        jTextArea1.setText(resourceMap.getString("jTextArea1.text")); // NOI18N
        jTextArea1.setWrapStyleWord(true);
        jTextArea1.setEnabled(false);
        jTextArea1.setName("jTextArea1"); // NOI18N
        jScrollPane2.setViewportView(jTextArea1);

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                    .addGroup(jDialog1Layout.createSequentialGroup()
                        .addComponent(jButton9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton8)))
                .addContainerGap())
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton9)
                    .addComponent(jButton8))
                .addContainerGap())
        );

        jDialog2.setName("jDialog2"); // NOI18N

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jSeparator1.setName("jSeparator1"); // NOI18N

        jFormattedTextField1.setName("jFormattedTextField1"); // NOI18N

        javax.swing.GroupLayout jDialog2Layout = new javax.swing.GroupLayout(jDialog2.getContentPane());
        jDialog2.getContentPane().setLayout(jDialog2Layout);
        jDialog2Layout.setHorizontalGroup(
            jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jFormattedTextField1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
                .addContainerGap())
        );
        jDialog2Layout.setVerticalGroup(
            jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jFormattedTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addContainerGap())
        );

        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new java.awt.GridBagLayout());

        jPanel3.setName("jPanel3"); // NOI18N

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 172, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addGap(71, 71, 71))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.ipadx = 166;
        gridBagConstraints.ipady = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(4, 0, 2, 0);
        jPanel2.add(jPanel3, gridBagConstraints);

        jPanel4.setName("jPanel4"); // NOI18N

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox1.setName("jComboBox1"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(69, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(96, Short.MAX_VALUE))
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.ipadx = 59;
        gridBagConstraints.ipady = 85;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        jPanel2.add(jPanel4, gridBagConstraints);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setForeground(resourceMap.getColor("Form.foreground")); // NOI18N
        setIconImages(null);
        setMaximizedBounds(new java.awt.Rectangle(0, 0, 2000, 500));
        setName("Form"); // NOI18N
        setResizable(false);

        jPanel1.setName("jPanel1"); // NOI18N

        jSeparator2.setName("jSeparator2"); // NOI18N

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator3.setName("jSeparator3"); // NOI18N

        jLabel6.setFont(jLabel6.getFont().deriveFont(jLabel6.getFont().getStyle() | java.awt.Font.BOLD, jLabel6.getFont().getSize()+1));
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        LearningRuleComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Hebbsche Lernregel", "Überwachtes Lernen" }));
        LearningRuleComboBox.setToolTipText(resourceMap.getString("LearningRuleComboBox.toolTipText")); // NOI18N
        LearningRuleComboBox.setName("LearningRuleComboBox"); // NOI18N
        LearningRuleComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                LearningRuleComboBoxItemStateChanged(evt);
            }
        });

        WeightModeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Zufallsgeneriert", "Selbst einstellen" }));
        WeightModeComboBox.setToolTipText(resourceMap.getString("WeightModeComboBox.toolTipText")); // NOI18N
        WeightModeComboBox.setName("WeightModeComboBox"); // NOI18N
        WeightModeComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                WeightModeComboBoxItemStateChanged(evt);
            }
        });

        StepModeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Schrittweise", "Durchlauf" }));
        StepModeComboBox.setToolTipText(resourceMap.getString("StepModeComboBox.toolTipText")); // NOI18N
        StepModeComboBox.setName("StepModeComboBox"); // NOI18N
        StepModeComboBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                StepModeComboBoxItemStateChanged(evt);
            }
        });

        StepValueSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100000, 1));
        StepValueSpinner.setToolTipText(resourceMap.getString("StepValueSpinner.toolTipText")); // NOI18N
        StepValueSpinner.setName("StepValueSpinner"); // NOI18N
        StepValueSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                StepValueSpinnerStateChanged(evt);
            }
        });

        StartCalculationButton.setText(resourceMap.getString("StartCalculationButton.text")); // NOI18N
        StartCalculationButton.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        StartCalculationButton.setName("StartCalculationButton"); // NOI18N
        StartCalculationButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StartCalculationButtonActionPerformed(evt);
            }
        });

        jLabel3.setFont(jLabel3.getFont().deriveFont(jLabel3.getFont().getStyle() | java.awt.Font.BOLD));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setFont(jLabel4.getFont().deriveFont(jLabel4.getFont().getStyle() | java.awt.Font.BOLD));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        InterruptCalculationButton.setText(resourceMap.getString("InterruptCalculationButton.text")); // NOI18N
        InterruptCalculationButton.setName("InterruptCalculationButton"); // NOI18N
        InterruptCalculationButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                InterruptCalculationButtonActionPerformed(evt);
            }
        });

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setFont(jLabel2.getFont().deriveFont(jLabel2.getFont().getStyle() | java.awt.Font.BOLD));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        Adjazenzmatrix.setName("Adjazenzmatrix"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jTable1.setName("jTable1"); // NOI18N
        jScrollPane1.setViewportView(jTable1);

        Adjazenzmatrix.addTab(resourceMap.getString("jScrollPane1.TabConstraints.tabTitle"), jScrollPane1); // NOI18N

        SetGraphButton.setText(resourceMap.getString("SetGraphButton.text")); // NOI18N
        SetGraphButton.setName("SetGraphButton"); // NOI18N
        SetGraphButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SetGraphButtonActionPerformed(evt);
            }
        });

        AddNodeToGraphButton.setText(resourceMap.getString("AddNodeToGraphButton.text")); // NOI18N
        AddNodeToGraphButton.setName("AddNodeToGraphButton"); // NOI18N
        AddNodeToGraphButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddNodeToGraphButtonActionPerformed(evt);
            }
        });

        AddEdgeToGraph.setText(resourceMap.getString("AddEdgeToGraph.text")); // NOI18N
        AddEdgeToGraph.setEnabled(false);
        AddEdgeToGraph.setName("AddEdgeToGraph"); // NOI18N
        AddEdgeToGraph.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddEdgeToGraphActionPerformed(evt);
            }
        });

        NodeLayerComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Eingabeschicht", "Ausgabeschicht" }));
        NodeLayerComboBox.setName("NodeLayerComboBox"); // NOI18N

        DeleteNodeFromGraph.setText(resourceMap.getString("DeleteNodeFromGraph.text")); // NOI18N
        DeleteNodeFromGraph.setEnabled(false);
        DeleteNodeFromGraph.setName("DeleteNodeFromGraph"); // NOI18N
        DeleteNodeFromGraph.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteNodeFromGraphActionPerformed(evt);
            }
        });

        jSeparator4.setName("jSeparator4"); // NOI18N

        DeleteEdgeFromGraph.setText(resourceMap.getString("DeleteEdgeFromGraph.text")); // NOI18N
        DeleteEdgeFromGraph.setEnabled(false);
        DeleteEdgeFromGraph.setName("DeleteEdgeFromGraph"); // NOI18N
        DeleteEdgeFromGraph.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteEdgeFromGraphActionPerformed(evt);
            }
        });

        DeleteNodeLayer.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Eingabeschicht", "Ausgabeschicht" }));
        DeleteNodeLayer.setEnabled(false);
        DeleteNodeLayer.setName("DeleteNodeLayer"); // NOI18N
        DeleteNodeLayer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteNodeLayerActionPerformed(evt);
            }
        });

        AddEgdeFromNode.setEnabled(false);
        AddEgdeFromNode.setName("AddEgdeFromNode"); // NOI18N

        AddEgdeToNode.setEnabled(false);
        AddEgdeToNode.setName("AddEgdeToNode"); // NOI18N

        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        DeleteEdgeComboBox.setEnabled(false);
        DeleteEdgeComboBox.setName("DeleteEdgeComboBox"); // NOI18N

        DeleteNodeComboBox.setEnabled(false);
        DeleteNodeComboBox.setName("DeleteNodeComboBox"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(StepModeComboBox, 0, 198, Short.MAX_VALUE)
                                    .addComponent(StepValueSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)
                                    .addComponent(WeightModeComboBox, 0, 198, Short.MAX_VALUE)
                                    .addComponent(LearningRuleComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(136, 136, 136))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(SetGraphButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addComponent(StartCalculationButton, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(InterruptCalculationButton, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(AddNodeToGraphButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(NodeLayerComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(DeleteNodeFromGraph, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(AddEdgeToGraph, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addComponent(DeleteEdgeFromGraph, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addComponent(DeleteNodeLayer, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(AddEgdeFromNode, javax.swing.GroupLayout.Alignment.LEADING, 0, 88, Short.MAX_VALUE))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel5)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(DeleteNodeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(AddEgdeToNode, 0, 92, Short.MAX_VALUE))
                                            .addGap(8, 8, 8))
                                        .addComponent(DeleteEdgeComboBox, 0, 145, Short.MAX_VALUE)))))
                        .addGap(101, 101, 101))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 378, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(Adjazenzmatrix, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 378, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(LearningRuleComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(WeightModeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(StepModeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(StepValueSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(SetGraphButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(StartCalculationButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(InterruptCalculationButton, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
                        .addGap(4, 4, 4)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(3, 3, 3)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(AddNodeToGraphButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(NodeLayerComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(5, 5, 5)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(AddEdgeToGraph, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(AddEgdeFromNode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)
                            .addComponent(AddEgdeToNode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(DeleteNodeFromGraph, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(DeleteNodeLayer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(DeleteNodeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(7, 7, 7)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(DeleteEdgeFromGraph, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(DeleteEdgeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Adjazenzmatrix, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(119, 119, 119)))
                .addContainerGap())
        );

        jFileChooser1.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
        jFileChooser1.setName("jFileChooser1"); // NOI18N

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N
        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenu2.add(jMenuItem1);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(174, 174, 174)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 458, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE)
                    .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void LearningRuleComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_LearningRuleComboBoxItemStateChanged
        if (LearningRuleComboBox.getSelectedIndex() == Hebb){
            this.LearningRule = "Hebbsche Lernregel";
        }
        else if (LearningRuleComboBox.getSelectedIndex() == Delta){
            this.LearningRule = "Ueberwachtes Lernen";
        }
    }//GEN-LAST:event_LearningRuleComboBoxItemStateChanged

    private void WeightModeComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_WeightModeComboBoxItemStateChanged
        if (WeightModeComboBox.getSelectedIndex() == Random){
            this.WightDefType = "Zufall";
        }
        else if (WeightModeComboBox.getSelectedIndex() == Self){
            this.WightDefType = "Selbst";
        }
    }//GEN-LAST:event_WeightModeComboBoxItemStateChanged

    private void StepModeComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_StepModeComboBoxItemStateChanged
        if (StepModeComboBox.getSelectedIndex() == Step){
            this.RunningType = "Schrittweise";
            StepValueSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, 10, 1));
            StepValueSpinner.setValue(1);
        }
        else if (StepModeComboBox.getSelectedIndex() == Run){
            this.RunningType = "Durchlauf";
            StepValueSpinner.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100000, 1));
            StepValueSpinner.setValue(100000);
        }
    }//GEN-LAST:event_StepModeComboBoxItemStateChanged

    private void StepValueSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_StepValueSpinnerStateChanged
        this.RunValue = (Integer)StepValueSpinner.getValue();
    }//GEN-LAST:event_StepValueSpinnerStateChanged
/**
     * Mit diesem Button startet man die Berechnungen mit den eingestellten Einstellungen.
     * Falls der Graph noch nicht endgültig vom Benutzer festgelegt wurde, wird eine
     * Meldung angezeigt, die den Benutzer auffordert den Graph festzulegen.
     *
     * => Noch nicht vollständig <=
     * @param evt
     */
    private void StartCalculationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartCalculationButtonActionPerformed
        if (this.SetGraphButton.getText() == null || this.SetGraphButton.getText().equals("Graph festlegen")){
            this.jDialog2.setVisible(true);
        }
        else{
            // Noch zu implementieren
        }
    }//GEN-LAST:event_StartCalculationButtonActionPerformed

    private void InterruptCalculationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_InterruptCalculationButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_InterruptCalculationButtonActionPerformed

    private void SetGraphButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SetGraphButtonActionPerformed

        if (this.SetGraphButton.getText() == null || this.SetGraphButton.getText().equals("Graph festlegen")){

            this.Box4 = this.NodeLayerComboBox.isEnabled();
            this.Box5 = this.DeleteNodeLayer.isEnabled();
            this.Box6 = this.DeleteEdgeComboBox.isEnabled();
            this.Box7 = this.AddEgdeFromNode.isEnabled();
            this.Box8 = this.AddEgdeToNode.isEnabled();
            this.Box9 = this.DeleteNodeComboBox.isEnabled();

            this.button4 = this.AddNodeToGraphButton.isEnabled();
            this.button5 = this.AddEdgeToGraph.isEnabled();
            this.button6 = this.DeleteNodeFromGraph.isEnabled();
            this.button7 = this.DeleteEdgeFromGraph.isEnabled();

            this.LearningRuleComboBox.setEnabled(false);
            this.WeightModeComboBox.setEnabled(false);
            this.StepModeComboBox.setEnabled(false);
            this.NodeLayerComboBox.setEnabled(false);
            this.DeleteNodeLayer.setEnabled(false);
            this.DeleteEdgeComboBox.setEnabled(false);
            this.AddEgdeFromNode.setEnabled(false);
            this.AddEgdeToNode.setEnabled(false);
            this.DeleteNodeComboBox.setEnabled(false);

            this.AddNodeToGraphButton.setEnabled(false);
            this.AddEdgeToGraph.setEnabled(false);
            this.DeleteNodeFromGraph.setEnabled(false);
            this.DeleteEdgeFromGraph.setEnabled(false);

            this.SetGraphButton.setText("Graph editieren");
            this.SetRandomWeightEgdes(this.graphGUI.getEdges());
            GraphVisualization.runVisualization(this.graphGUI, this);
            ADmatrixausgabeGUI(this.graphGUI.getMatrix().getValues(), this);
        }
        else{
            this.LearningRuleComboBox.setEnabled(true);
            this.WeightModeComboBox.setEnabled(true);
            this.StepModeComboBox.setEnabled(true);
            this.NodeLayerComboBox.setEnabled(Box4);
            this.DeleteNodeLayer.setEnabled(Box5);
            this.DeleteEdgeComboBox.setEnabled(Box6);
            this.AddEgdeFromNode.setEnabled(Box7);
            this.AddEgdeToNode.setEnabled(Box8);
            this.DeleteNodeComboBox.setEnabled(Box9);

            this.AddNodeToGraphButton.setEnabled(button4);
            this.AddEdgeToGraph.setEnabled(button5);
            this.DeleteNodeFromGraph.setEnabled(button6);
            this.DeleteEdgeFromGraph.setEnabled(button7);

            this.SetGraphButton.setText("Graph festlegen");
        }
    }//GEN-LAST:event_SetGraphButtonActionPerformed

    private void AddNodeToGraphButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddNodeToGraphButtonActionPerformed
        Node neu = null;
        if (this.AddEgdeFromNode.getItemCount() > 0 && this.NodeLayerComboBox.getSelectedIndex() == 1 || this.AddEgdeToNode.getItemCount() > 0){
            this.AddEdgeToGraph.setEnabled(true);
            this.AddEgdeFromNode.setEnabled(true);
            this.AddEgdeToNode.setEnabled(true);
            this.DeleteNodeLayer.setEnabled(true);
        }
        else {
            this.AddEdgeToGraph.setEnabled(false);
            this.AddEgdeFromNode.setEnabled(false);
            this.AddEgdeToNode.setEnabled(false);
            this.DeleteNodeLayer.setEnabled(false);
        }
        if(this.NodeLayerComboBox.getSelectedIndex() == 0){
            neu = new Layer1Node(""+KnotenNumber);
            this.graphGUI.addNode(neu);
            this.KnotenNumber++;
            this.AddEgdeFromNode.addItem(neu.getName());
        }
        else {
            neu = new Layer2Node(""+KnotenNumber);
            this.graphGUI.addNode(neu);
            this.KnotenNumber++;
            this.AddEgdeToNode.addItem(neu.getName());
        }
        this.DeleteNodeFromGraph.setEnabled(true);
        this.DeleteNodeLayer.setEnabled(true);
        this.DeleteNodeComboBox.setEnabled(true);
        DeleteNodeLayerActionPerformed(evt);
    }//GEN-LAST:event_AddNodeToGraphButtonActionPerformed

    private void AddEdgeToGraphActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddEdgeToGraphActionPerformed
        int Knoten1 = this.AddEgdeFromNode.getSelectedIndex();
        int Knoten2 = this.AddEgdeToNode.getSelectedIndex();

        Node Layer1 = this.graphGUI.getNodes().get(Knoten1);
        Node Layer2 = this.graphGUI.getNodes().get(Knoten1+Knoten2+1);
        Edge neu = new Edge(Layer1, Layer2, 1, "Kante von Knoten"+Layer1.getName()+" zu Knoten"+Layer2.getName());
        this.graphGUI.addEdge(neu);
        this.DeleteEdgeComboBox.addItem(neu.getName());
        this.DeleteEdgeComboBox.setEnabled(true);
        this.DeleteEdgeFromGraph.setEnabled(true);
    }//GEN-LAST:event_AddEdgeToGraphActionPerformed

    private void DeleteEdgeFromGraphActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteEdgeFromGraphActionPerformed
        Edge del = this.graphGUI.getEdges().get(this.DeleteEdgeComboBox.getSelectedIndex());
        this.graphGUI.deleteEdge(del);
        this.DeleteEdgeComboBox.removeItemAt(this.DeleteEdgeComboBox.getSelectedIndex());
        if (this.DeleteEdgeComboBox.getItemCount() < 1){
            this.DeleteEdgeComboBox.setEnabled(false);
            this.DeleteEdgeFromGraph.setEnabled(false);
        }
        this.KantenNumber--;
    }//GEN-LAST:event_DeleteEdgeFromGraphActionPerformed
/**
 * Diese Methode ist noch nicht fertig. Problem ist hier, die passenden Knoten zu finden, die gelöscht werden sollen!
 * @param evt
 */
    private void DeleteNodeFromGraphActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteNodeFromGraphActionPerformed
        int count = 0;
        Node del = null;
        for (int i = 0; i < this.graphGUI.getNodes().size(); i++){
            if (this.graphGUI.getNodes().get(i).getName().equals(this.DeleteNodeComboBox.getSelectedItem())){
                del = this.graphGUI.getNodes().get(i);
            }
        }
        for (int i = 0; i < this.graphGUI.getEdges().size(); i++){
                if (this.graphGUI.getEdges().get(i).getFrom().getName().equals(del.getName()) || this.graphGUI.getEdges().get(i).getTo().getName().equals(del.getName())){
                    count++;
                }
            }
        if(del != null && count > 0){
            this.jDialog1.setVisible(true);
        }
        else if (del != null){
            this.graphGUI.deleteNode(del);
            this.DeleteNodeComboBox.removeItemAt(this.DeleteNodeComboBox.getSelectedIndex());
            this.KnotenNumber--;
            if (this.KnotenNumber < 2){
                this.AddEdgeToGraph.setEnabled(false);
                this.AddEgdeFromNode.setEnabled(false);
                this.AddEgdeToNode.setEnabled(false);
            }
            if (del instanceof Layer1Node){
                for (int i = 0; i < this.AddEgdeFromNode.getItemCount(); i++){
                    if (this.AddEgdeFromNode.getItemAt(i).equals(del.getName())){
                        this.AddEgdeFromNode.removeItemAt(i);
                    }
                }
            }
            else {
                for (int i = 0; i < this.AddEgdeToNode.getItemCount(); i++){
                    if (this.AddEgdeToNode.getItemAt(i).equals(del.getName())){
                        this.AddEgdeToNode.removeItemAt(i);
                    }
                }
            }
        }
        if (this.graphGUI.getNodes().size() < 1){
            this.DeleteNodeFromGraph.setEnabled(false);
            this.DeleteNodeLayer.setEnabled(false);
            this.DeleteNodeComboBox.setEnabled(false);
        }
    }//GEN-LAST:event_DeleteNodeFromGraphActionPerformed

    private void DeleteNodeLayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteNodeLayerActionPerformed
        this.DeleteNodeComboBox.removeAllItems();
        if (this.DeleteNodeLayer.getSelectedIndex() == 0){
            for (int i = 0; i < this.graphGUI.getNodes().size(); i++){
                if (this.graphGUI.getNodes().get(i) instanceof Layer1Node){
                    this.DeleteNodeComboBox.addItem(this.graphGUI.getNodes().get(i).getName());
                }
            }
        }
        else {
            for (int i = 0; i < this.graphGUI.getNodes().size(); i++){
                if (this.graphGUI.getNodes().get(i) instanceof Layer2Node){
                    this.DeleteNodeComboBox.addItem(this.graphGUI.getNodes().get(i).getName());
                }
            }
        }
        if (this.DeleteNodeComboBox.getItemCount() < 1){
            this.DeleteNodeComboBox.setEnabled(false);
            this.DeleteNodeFromGraph.setEnabled(false);
        }
        else{
            this.DeleteNodeComboBox.setEnabled(true);
            this.DeleteNodeFromGraph.setEnabled(true);
        }
        if (this.graphGUI.getNodes().size() < 1){
            this.DeleteNodeFromGraph.setEnabled(false);
            this.DeleteNodeLayer.setEnabled(false);
        }
    }//GEN-LAST:event_DeleteNodeLayerActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        Node del = null;
        for (int i = 0; i < this.graphGUI.getNodes().size(); i++){
            if (this.graphGUI.getNodes().get(i).getName().equals(this.DeleteNodeComboBox.getSelectedItem())){
                del = this.graphGUI.getNodes().get(i);
            }
        }
        if (del != null){
            for (int i = 0; i < del.getIncomingEdges().size(); i++){
                this.graphGUI.deleteEdge(del.getIncomingEdges().get(i));
                this.KantenNumber--;
                for (int m = 0; m < this.DeleteEdgeComboBox.getItemCount(); m++){
                    System.out.println(del.getName());
                    if (this.DeleteEdgeComboBox.getItemAt(m).toString().endsWith(del.getName())){
                        this.DeleteEdgeComboBox.removeItemAt(m);
                        if (this.KantenNumber < 1){
                            this.DeleteEdgeComboBox.setEnabled(false);
                            this.DeleteEdgeFromGraph.setEnabled(false);
                        }
                    }
                }
            }
            for (int j = 0; j < del.getOutgoingEdges().size(); j++){
                this.graphGUI.deleteEdge(del.getOutgoingEdges().get(j));
                this.KantenNumber--;
                for (int m = 0; m < this.DeleteEdgeComboBox.getItemCount(); m++){
                    if (this.DeleteEdgeComboBox.getItemAt(m).toString().contains(del.getName())){
                        this.DeleteEdgeComboBox.removeItemAt(m);
                        if (this.KantenNumber < 1){
                            this.DeleteEdgeComboBox.setEnabled(false);
                            this.DeleteEdgeFromGraph.setEnabled(false);
                        }
                    }
                }
            }
            for (int i = 0; i < this.graphGUI.getEdges().size(); i++){
                if (this.graphGUI.getEdges().get(i).getFrom().getName().equals(del.getName()) || this.graphGUI.getEdges().get(i).getTo().getName().equals(del.getName())){
                    this.graphGUI.getEdges().removeElementAt(i);
                }
            }
        }
        this.jDialog1.setVisible(false);
    }//GEN-LAST:event_jButton8ActionPerformed
/**
 * Beendet das Fenster und kehrt zum Hauptfenster zurueck
 * @param evt
 */
    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        this.jDialog1.dispose();
    }//GEN-LAST:event_jButton9ActionPerformed
/**
 * Beendet das Fenster und kehrt zum Hauptfenster zurueck
 * @param evt
 */
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        this.jDialog2.setVisible(false);
    }//GEN-LAST:event_jButton3ActionPerformed
/**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
     Graph graph = new Graph();

        //Erzeuge Nodes & Edges
     /*
        Node knoten1 = new Layer1Node("K1-Layer1");
        Node knoten2 = new Layer1Node("K2-Layer1");
        Node knoten3 = new Layer2Node("K3-Layer2");
        Node knoten4 = new Layer2Node("K4-Layer2");
        Node knoten5 = new Layer1Node("K5-Layer1"); //erz. namenlosen knoten

        double gewicht = 1;
        Edge kante1zu3 = new Edge(knoten1, knoten3, gewicht);
        Edge kante1zu4 = new Edge(knoten1, knoten4, .2);
        Edge kante2zu4 = new Edge(knoten2, knoten4, .0);
        Edge kante5zu3 = new Edge(knoten5, knoten3, gewicht);
        Edge kante5zu4 = new Edge(knoten5, knoten4, .4);

        knoten1.setOutputValue(2);
        knoten2.setOutputValue(1);
        knoten5.setOutputValue(1);



        //test nettoInput for Knoten4: (Test succesfull 30.11.09, Miri)
        double net4 = knoten4.nettoinput();
        System.out.println("NettoInput für Knoten4: " + net4);

        //add edges to graph
        graph.addEdge(kante2zu4);
        graph.addEdge(kante1zu3);
        graph.addEdge(kante1zu4);
        graph.addEdge(kante5zu3);
        graph.addEdge(kante5zu4);
        SetRandomWeightEgdes(graph.getEdges());

        graph.addNode(knoten1);
        graph.addNode(knoten2);
        graph.addNode(knoten3);
        graph.addNode(knoten4);
        graph.addNode(knoten5);

        System.out.println("Adjazenzmatrix vom Graph \n" + graph.getMatrix());

        System.out.println("graph:" + graph);

        //Converting the graph to GraphML (XML for graphs) [WORKS!]
        System.out.println("GraphML-Dokument:\n" + GraphMLDocumentBuilder.convertToGraphMLAsString(graph));



        Vector<Edge> alleKanten_K3 = knoten3.getEdges();
        System.out.println("alle Kanten: " + vectorToString(alleKanten_K3));
        Vector<Edge> eingehKanten_K3 = knoten3.getIncomingEdges();
        System.out.println("eingehende Kanten: " + vectorToString(eingehKanten_K3));
        Vector<Edge> ausgehKanten_K3 = knoten3.getOutgoingEdges();
        System.out.println("alle Kanten: " + vectorToString(ausgehKanten_K3));

        int anzKanten = alleKanten_K3.size();
        System.out.println("Knoten 3 besitzt insgesamt " + anzKanten + " Kanten;");

        anzKanten = eingehKanten_K3.size();
        System.out.println("davon sind insgesamt " + anzKanten + " ausgehende Kanten;");
      *
      */
        
     WindowGUI neu = new WindowGUI();
     neu.setDefaultLookAndFeelDecorated(true);
        //GraphVisualization.runVisualization(graph, neu);
        //ADmatrixausgabeGUI(this.graphGUI.getMatrix().getValues(), this);
        // Beginn the Init of the graph
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddEdgeToGraph;
    private javax.swing.JComboBox AddEgdeFromNode;
    private javax.swing.JComboBox AddEgdeToNode;
    private javax.swing.JButton AddNodeToGraphButton;
    private javax.swing.JTabbedPane Adjazenzmatrix;
    private javax.swing.JComboBox DeleteEdgeComboBox;
    private javax.swing.JButton DeleteEdgeFromGraph;
    private javax.swing.JComboBox DeleteNodeComboBox;
    private javax.swing.JButton DeleteNodeFromGraph;
    private javax.swing.JComboBox DeleteNodeLayer;
    private javax.swing.JButton InterruptCalculationButton;
    private javax.swing.JComboBox LearningRuleComboBox;
    private javax.swing.JComboBox NodeLayerComboBox;
    private javax.swing.JButton SetGraphButton;
    private javax.swing.JButton StartCalculationButton;
    private javax.swing.JComboBox StepModeComboBox;
    private javax.swing.JSpinner StepValueSpinner;
    private javax.swing.JComboBox WeightModeComboBox;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JDialog jDialog2;
    private javax.swing.JFileChooser jFileChooser1;
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables
    
    private void SetRandomWeightEgdes(Vector <Edge> edge) {
        for (int i  = 0; i < edge.size(); i++){
            double index = (double)(Math.random());
            index = Math.round(index * 100 ) / 100.0;
            edge.get(i).setWeight(index);
        }
    }

    public static String vectorToString(Vector<?> vector) {
       StringBuffer str = new StringBuffer();
       if (vector != null) {
           for (int i = 0; i < vector.size(); i++) {
               str.append(vector.get(i).toString() + ", ");
           }
       }
       return str.toString();
   }

     private static void ADmatrixausgabeGUI(double[][] matrix, WindowGUI window) {
        DefaultTableModel tModel = new DefaultTableModel();
        tModel.setColumnCount(matrix.length);
        tModel.setRowCount(matrix[0].length);
        window.jTable1.updateUI();
        for (int i = 0; i < matrix.length; i++){
            for (int j = 0; j < matrix[0].length; j++){
                tModel.setValueAt(matrix[i][j], j, i);
            }
        }
        window.jTable1.setModel(tModel);
        window.jTable1.updateUI();
    }
}
